<?php

    $GLOBALS['develop'] = 1; // 0 = public mode, 1 = develop mode

    // Develop options
    if($GLOBALS['develop'] == 1) {
        error_reporting(E_ALL);
    }
    else {
        error_reporting(0);
    }

    // settings
    require_once('func/settings.inc.php');

    // global functions
    require_once('func/globalfunc.inc.php');

    // mysql connection
    require_once('func/mysql.inc.php');

    // user class
    require_once('func/class.user.php');

    // Language class
    require_once('func/class.language.php');

    // Modul class
    require_once('func/class.modul.php');

    // modul functions
    require_once('func/modulfunc.inc.php');

    // validation functions
    require_once('func/validfunc.inc.php');

    if(isset($_SESSION['userID'])) {
        // check if Session userID is valid
        if(isValidUserID($_SESSION['userID']) == 2) {
            $currentUser = new User($_SESSION['userID']);
        }
        else {
            unset($_SESSION['userID']);
            $currentUser = new User(0);
        }
    }
    else {
        $currentUser = new User(0);
    }

    // create Language
    $indexLanguage = new Language;

    // read settings from database
    $res_settings = execute_query("SELECT keywords, pagename, pagetitle, designfile FROM %PRE%settings",$MySQL_DB);
    if($settings = $res_settings->fetch_object()) {
        $page_keywords = $settings->keywords;
        $pagename = $indexLanguage->translation($settings->pagename, 'pagename', 1);
        $pagetitle = $indexLanguage->translation($settings->pagetitle, 'pagetitle', 1);
        $design_file = $settings->designfile;
    }
    // no settings? write error log
    else {
        write_errorlog('No settings loaded from database',1,'function.php');
    }

    // include design
    if(file_exists('design/'.$design_file.'.php')) {
        $indexModul = new Modul(0,$indexLanguage);
        include('design/'.$design_file.'.php');
    }
    else {
        write_errorlog("Selected design file not available! file: ".$design_file,1,"design");
    }

?>